<template>
  <div>
    <mt-swipe :auto="4000">
      <mt-swipe-item v-for="(item, index) in swipper" :key="index">
        <img :src="item.image" alt="">
      </mt-swipe-item>
    </mt-swipe>
  </div>
</template>

<script>
import { Toast } from "mint-ui";
export default {
  data() {
    return {
      swipper: []
    };
  },
  created() {
    this.getSwipper();
  },
  methods: {
    getSwipper() {
      this.$http.get("http://localhost/vue/api.php?name=swipper").then(res => {
        if (res.body.status === 0) {
          this.swipper = res.body.message;
        } else {
          Toast("获取轮播图失败");
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
.mint-swipe {
  height: 140px;
  .mint-swipe-item {
    &:nth-child(1) {
      background-color: antiquewhite;
    }
    &:nth-child(2) {
      background-color: beige;
    }
    &:nth-child(3) {
      background-color: burlywood;
    }
    img{
      width: 100%;
      height: auto;
    }
  }
}
</style>